﻿<%@ Page Language="C#" MasterPageFile="~/Safty/MasterPage.master" AutoEventWireup="true" CodeFile="UserListReply.aspx.cs" Inherits="Safty_UserListReply" Title="无标题页" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script type="text/javascript">
        var template = '<span style="color:{0};">{1}</span>';

        var Shenhe = function (value) {
            if(value==0){return String.format(template,'red', '未审');}
            if(value==1){return String.format(template,'green', '同意');}
            if(value==2){return String.format(template,'blue', '退回');}
        }
    </script>
     <ext:TokenScript ID="TokenScript1" runat="server">
        <script type="text/javascript">
            var applyFilter = function () {
                #{Store1}.filterBy(getRecordFilter());
            }
            
            var clearFilter = function () {
                #{CompanyFilter}.reset();
                #{sidFilter}.reset();
                #{deptFilter}.reset();                 
                #{ComboBox1}.reset();
                #{ComboBox2}.reset();
                #{ComboBox3}.reset();
                #{Store1}.clearFilter();
            }

            var filterString = function (value, dataIndex, record) {
                var val = record.get(dataIndex);
                if (typeof val != "string") {
                    return value.length == 0;
                }
                return val.toLowerCase().indexOf(value.toLowerCase()) > -1;
            }

            var filterDate = function (value, dataIndex, record) {
                var val = record.get(dataIndex).clearTime(true).getTime();

                if (!Ext.isEmpty(value, false) && val != value.clearTime(true).getTime()) {
                    return false;
                }
                return true;
            }

            var filterNumber = function (value, dataIndex, record) {
                var val = record.get(dataIndex);			    

                if (!Ext.isEmpty(value, false) && val != value) {
                    return false;
                }
                return true;
            }

            var getRecordFilter = function () {
                var f = [];

                f.push({
                    filter: function(record) {                         
                        return filterNumber(#{sidFilter}.getValue(), 'SID', record);
                    }
                });
                f.push({
                    filter: function(record) {                         
                        return filterString(#{CompanyFilter}.getValue(), 'EN_Username', record);
                    }
                }); 
                f.push({
                    filter: function(record) {                         
                        return filterString(#{deptFilter}.getValue(), 'EN_Department', record);
                    }
                });
                f.push({
                    filter: function(record) {                         
                        return filterNumber(#{ComboBox1}.getValue(), 'Safty_Master_Status', record);
                    }
                });
                f.push({
                    filter: function(record) {                         
                        return filterNumber(#{ComboBox2}.getValue(), 'Boss_Status', record);
                    }
                });
                f.push({
                    filter: function(record) {                         
                        return filterNumber(#{ComboBox3}.getValue(), 'Dept_Master_Status', record);
                    }
                });

                var len = f.length;
                return function(record) {
                    for (var i = 0; i < len; i++) {
                        if (!f[i].filter(record)) {
                            return false;
                        }
                    }
                    return true;
                };
            }  
        </script>
    </ext:TokenScript>
    <ext:Store ID="Store1" OnRefreshData="Store1_OnRefreshData"   runat="server">
                                <Reader>
                                    <ext:JsonReader ReaderID="SID">
                                        <Fields>
                                            <ext:RecordField Name="SID" Type="Int" ></ext:RecordField>
                                            <ext:RecordField Name="EN_Username" Type="String" ></ext:RecordField>
                                            <ext:RecordField Name="EN_Department" Type="String"></ext:RecordField>
                                            <ext:RecordField Name="Safty_Master_Status" Type="Int"></ext:RecordField>
                                            <ext:RecordField Name="Boss_Status" Type="Int"></ext:RecordField>
                                            <ext:RecordField Name="Dept_Master_Status" Type="Int"></ext:RecordField>
                                        </Fields>
                                    </ext:JsonReader>
                                </Reader>
                                    <AutoLoadParams>
                                         <ext:Parameter Name="start" Mode="Raw" Value="0" />
                                         <ext:Parameter Name="limit" Mode="raw" Value="10" />
                                     </AutoLoadParams> 
                                </ext:Store>
                                <asp:SqlDataSource ID="SqlDataSource1"
                            ConnectionString="<%$ ConnectionStrings:CXDB %>" 
                             SelectCommand="Select username from cx_userbase"
                             runat="server"></asp:SqlDataSource>
                               <ext:Store ID="usernameStore" DataSourceID="SqlDataSource1" runat="server">
                                    <Reader>
                                        <ext:JsonReader ReaderID="username">
                                            <Fields>
                                                <ext:RecordField Name="username" />
                                            </Fields>
                                        </ext:JsonReader>
                                    </Reader>
                                </ext:Store>
                                <asp:SqlDataSource ID="SqlDataSource3"
                            ConnectionString="<%$ ConnectionStrings:CXDB %>" 
                             SelectCommand="Select DeptName from cx_sys_dept"
                             runat="server"></asp:SqlDataSource>
                               <ext:Store ID="deptStore" DataSourceID="SqlDataSource3" runat="server">
                                    <Reader>
                                        <ext:JsonReader ReaderID="DeptName">
                                            <Fields>
                                                <ext:RecordField Name="DeptName" />
                                            </Fields>
                                        </ext:JsonReader>
                                    </Reader>
                                </ext:Store>
                                <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:CXDB %>" 
                                SelectCommand="SELECT [username], [uID] FROM [CX_UserBase] WHERE ([DEPID] = @DEPID)">
                                <SelectParameters>
                                    <asp:Parameter DefaultValue="1" Name="DEPID" Type="Int32" />
                                </SelectParameters>
                            </asp:SqlDataSource>
                            <ext:Store ID="Store2" DataSourceID="SqlDataSource2" runat="server">
                            <Reader>
                                <ext:JsonReader ReaderID="uID">
                                    <Fields>
                                        <ext:RecordField Name="uID" Type="Int"></ext:RecordField>
                                        <ext:RecordField Name="username" Type="String" ></ext:RecordField>
                                    </Fields>
                                </ext:JsonReader>
                            </Reader>
                            </ext:Store>
                            <ext:Store ID="Store3"   runat="server">
                                <Reader>
                                    <ext:JsonReader ReaderID="uID">
                                        <Fields>
                                            <ext:RecordField Name="uID" Type="Int"></ext:RecordField>
                                            <ext:RecordField Name="username" Type="String"></ext:RecordField>
                                        </Fields>
                                    </ext:JsonReader>
                                </Reader>
                            </ext:Store>
    <ext:ViewPort ID="ViewPort1" runat="server">
        <Body>
            <ext:ColumnLayout  ID="ColumnLayout1" runat="server" Split="true" FitHeight="true">
                <Columns>
                <ext:LayoutColumn ColumnWidth="0.4">
                                <ext:GridPanel AutoExpandColumn="ED_Username" ID="GridPanel1" runat="server" Height="600" StoreID="Store1" Title="员工列表" TrackMouseOver="true" Icon="UserHome">
                                <ColumnModel ID="ColumnModel1" runat="server">
                                    <Columns>
                                        <ext:Column DataIndex="SID" ColumnID="SID" Header="报表编号"></ext:Column>
                                        <ext:Column DataIndex="EN_Username" ColumnID="ED_Username" Header="员工姓名"></ext:Column>
                                        <ext:Column DataIndex="EN_Department" ColumnID="ED_DeptName" Header="所在部门"></ext:Column>
                                        <ext:Column DataIndex="Safty_Master_Status" ColumnID="Safty_Master_Status" Header="安监领导审核状态">
                                        <Renderer Fn="Shenhe" />
                                        </ext:Column>
                                        <ext:Column DataIndex="Boss_Status" ColumnID="Boss_Status" Header="公司领导审核状态">
                                        <Renderer Fn="Shenhe" />
                                        </ext:Column>
                                        <ext:Column DataIndex="Dept_Master_Status" ColumnID="Dept_Master_Status" Header="部门领导审核状态">
                                        <Renderer Fn="Shenhe" />
                                        </ext:Column>
                                        <ext:Column Width="28" DataIndex="company" Sortable="false" MenuDisabled="true" Header="&nbsp;" Fixed="true">
                                            <Renderer Handler="return '';" />
                                        </ext:Column>
                                    </Columns>
                                </ColumnModel>
                                <SelectionModel>
                                            <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
                                                <AjaxEvents>
                                                    <RowSelect OnEvent="RowSelect" Buffer="250">
                                                        <EventMask  ShowMask="true" Target="CustomTarget" CustomTarget="#{ReportReply}" />
                                                        <ExtraParams>
                                                            <%-- or can use params[2].id as value --%>
                                                            <ext:Parameter Name="ida" Value="params[2].id" Mode="Raw" />
                                                        </ExtraParams>
                                                    </RowSelect>
                                                </AjaxEvents>
                                            </ext:RowSelectionModel>
                                        </SelectionModel>
                                        <View>
                                    <ext:GridView ID="GridView1" runat="server">
                                        <HeaderRows>
                                            <ext:HeaderRow>
                                                <Columns>
                                                    <ext:HeaderColumn>
                                                        <Component>
                                                            <ext:TextField ID="sidFilter" runat="server" EnableKeyEvents="true">
                                                                <Listeners>
                                                                    <KeyUp Handler="applyFilter();" Buffer="250" />                                                
                                                                </Listeners>
                                                            </ext:TextField>
                                                        </Component>
                                                    </ext:HeaderColumn>
                                                    <ext:HeaderColumn>
                                                        <Component>
                                                            <ext:ComboBox ID="CompanyFilter" runat="server" 
                                                                StoreID="usernameStore"
                                                                TriggerAction="All"
                                                                Mode="Local"
                                                                DisplayField="username"
                                                                ValueField="username">    
                                                                <Listeners>
                                                                    <Select Handler="applyFilter();" />
                                                                </Listeners>     
                                                            </ext:ComboBox>
                                                        </Component>
                                                    </ext:HeaderColumn>
                                                    <ext:HeaderColumn Cls="x-small-editor">
                                                        <Component>
                                                            <ext:ComboBox ID="deptFilter" runat="server" 
                                                                StoreID="deptStore"
                                                                TriggerAction="All"
                                                                Mode="Local"
                                                                DisplayField="DeptName"
                                                                ValueField="DeptName">    
                                                                <Listeners>
                                                                    <Select Handler="applyFilter();" />
                                                                </Listeners>     
                                                            </ext:ComboBox>
                                                        </Component>
                                                    </ext:HeaderColumn>
                                                    <ext:HeaderColumn>
                                                        <Component>
                                                            <ext:ComboBox ID="ComboBox1" runat="server"                                                                  
                                                                TriggerAction="All"
                                                                Mode="Local">
                                                                <Items>
                                                                    <ext:ListItem Text="同意" Value="1" />
                                                                    <ext:ListItem Text="未审核" Value="0" />
                                                                    <ext:ListItem Text="退回" Value="2" />
                                                                </Items>    
                                                                <Listeners>
                                                                    <Select Handler="applyFilter();" />
                                                                </Listeners>     
                                                            </ext:ComboBox>
                                                        </Component>
                                                    </ext:HeaderColumn>
                                                    <ext:HeaderColumn>
                                                        <Component>
                                                         <ext:ComboBox ID="ComboBox2" runat="server"                                                                  
                                                                TriggerAction="All"
                                                                Mode="Local">
                                                                <Items>
                                                                    <ext:ListItem Text="同意" Value="1" />
                                                                    <ext:ListItem Text="未审核" Value="0" />
                                                                    <ext:ListItem Text="退回" Value="2" />
                                                                </Items>    
                                                                <Listeners>
                                                                    <Select Handler="applyFilter();" />
                                                                </Listeners>     
                                                            </ext:ComboBox>
                                                        </Component>
                                                    </ext:HeaderColumn>
                                                    <ext:HeaderColumn>
                                                        <Component>
                                                             <ext:ComboBox ID="ComboBox3" runat="server"                                                                  
                                                                TriggerAction="All"
                                                                Mode="Local">
                                                                <Items>
                                                                    <ext:ListItem Text="同意" Value="1" />
                                                                    <ext:ListItem Text="未审核" Value="0" />
                                                                    <ext:ListItem Text="退回" Value="2" />
                                                                </Items>    
                                                                <Listeners>
                                                                    <Select Handler="applyFilter();" />
                                                                </Listeners>     
                                                            </ext:ComboBox>
                                                        </Component>
                                                    </ext:HeaderColumn>
                                                    <ext:HeaderColumn AutoWidthElement="false">
                                                        <Component>
                                                            <ext:Button ID="ClearFilterButton" runat="server" Icon="Cancel">
                                                                <ToolTips>
                                                                    <ext:ToolTip ID="ToolTip1" runat="server" Html="清空选择" />
                                                                </ToolTips>
                                                                
                                                                <Listeners>
                                                                    <Click Handler="clearFilter();" />
                                                                </Listeners>                                            
                                                            </ext:Button>
                                                        </Component>
                                                    </ext:HeaderColumn>  
                                                </Columns>
                                            </ext:HeaderRow>
                                        </HeaderRows>
                                    </ext:GridView>
                                 </View>
                                        <BottomBar>
                                            <ext:PagingToolBar 
                                                ID="PagingToolBar1" 
                                                runat="server" 
                                                PageSize="10" 
                                                StoreID="Store1" 
                                                />
                                        </BottomBar>
                                        <LoadMask ShowMask="true" />
                                </ext:GridPanel>
 
                </ext:LayoutColumn>
                    
              <ext:LayoutColumn ColumnWidth="0.6"> 
                            
                            <ext:FormPanel ID="FormPanel1" LabelWidth="150"    AutoScroll="true"   Title="员工诚信档案记录表"  runat="server" BodyStyle="padding:5px;" ButtonAlign="Right"
                                Frame="true" >
                                <Body>
                                    
                                    <ext:FormLayout  LabelStyle="color:blue;" ID="FormLayout1" runat="server">
                                        <ext:Anchor>
                                            <ext:Label ID="IDLabel" runat="server" FieldLabel="报表编号"></ext:Label>
                                        </ext:Anchor>
                                        
                                        <ext:Anchor>
                                            <ext:Hidden ID="TfUserId"   runat="server" FieldLabel="员工编号">
                                            </ext:Hidden>
                                        </ext:Anchor>
                                         <ext:Anchor>
                                            <ext:Hidden ID="rID"   runat="server" FieldLabel="报表编号">
                                            </ext:Hidden>
                                        </ext:Anchor>
                                        <ext:Anchor>
                                            <ext:Hidden ID="tfguid" runat="server"></ext:Hidden>
                                        </ext:Anchor>
                                        <ext:Anchor>
                                            <ext:Label ID="TfUserName" FieldLabel="员工姓名" runat="server"></ext:Label>
                                        </ext:Anchor>
                                        <ext:Anchor>
                                            <ext:Label ID="TfDeptName"   runat="server" FieldLabel="所在部门">
                                            </ext:Label>
                                        </ext:Anchor>
                                        <ext:Anchor>
                                            <ext:Hidden ID="TfDeptID" runat="server"  FieldLabel="部门ID"></ext:Hidden>
                                        </ext:Anchor>
                                        <ext:Anchor>
                                            <ext:Label ID="TfAccident_time"     FieldLabel="安全生产中的事故时间" runat="server">
                                            </ext:Label>
                                        </ext:Anchor>
                                        <ext:Anchor>
                                            <ext:Label runat="server" ID="TfAccident_Duty" FieldLabel="安全生产中的事故责任类型">
                                                            </ext:Label>
                                        </ext:Anchor>
                                        <ext:Anchor>
                                            <ext:Label ID="TfAccident_reason" FieldLabel="安全生产中的事故原因" runat="server">
                                            </ext:Label>
                                        </ext:Anchor>
                                        <ext:Anchor>
                                            <ext:HyperLink runat="server" ID="tffileshow" FieldLabel="附件"></ext:HyperLink>
                                        </ext:Anchor>
                                        <ext:Anchor>
                                            <ext:Label ID="TfEntering_username" FieldLabel="录入员" runat="server"></ext:Label>
                                        </ext:Anchor>
                                        <ext:Anchor>
                                            <ext:ComboBox ID="TfDept_Master_ID" runat="server"
                                                            StoreID="Store3"
                                                            Disabled="true"
                                                            FieldLabel="发送至部门领导"
                                                            ValueField="uID"
                                                            DisplayField="username"
                                                            EmptyText="请选择"
                                                            Editable="false"></ext:ComboBox>
                                        </ext:Anchor>
                                        
                                        <ext:Anchor>
                                            <ext:ComboBox ID="TfBoss_ID" runat="server"
                                                            Disabled="true"
                                                            StoreID="Store2"
                                                            FieldLabel="发送至公司领导" 
                                                            ValueField="uID" 
                                                            DisplayField="username"   
                                                            EmptyText="请选择" 
                                                            Editable="false" >
                                            </ext:ComboBox>
                                        </ext:Anchor>
                                        <ext:Anchor>
                                            <ext:ComboBox FieldLabel="安监领导审核状态" Disabled="true" ID="TfSafty_Master_Status" runat="server" EmptyText="请选择" Editable="false">
                                                <Items>
                                                    <ext:ListItem Text="未审核" Value="0" />
                                                    <ext:ListItem Text="同意" Value="1" />
                                                    <ext:ListItem Text="退回" Value="2" />
                                                </Items>
                                            </ext:ComboBox>
                                        </ext:Anchor>
                                        <ext:Anchor Horizontal="100%">
                                            <ext:TextArea FieldLabel="安监领导审核意见" Disabled="true"  ID="TfSafty_master_remark" runat=server></ext:TextArea>
                                        </ext:Anchor> 
                                        <ext:Anchor>
                                            <ext:ComboBox FieldLabel="部门领导审核状态" Disabled="true"  ID="TfDept_master_status_Comb" runat="server" EmptyText="请选择" Editable="false">
                                                <Items>
                                                    <ext:ListItem Text="未审核" Value="0" />
                                                    <ext:ListItem Text="同意" Value="1" />
                                                    <ext:ListItem Text="退回" Value="2" />
                                                </Items>
                                            </ext:ComboBox>
                                        </ext:Anchor>
                                        <ext:Anchor Horizontal="100%">
                                            <ext:TextArea  ID="TfDept_Master_Remark" Disabled="true"  runat="server" FieldLabel="部门领导审核意见" ></ext:TextArea>
                                        </ext:Anchor> 
                                        <ext:Anchor>
                                            <ext:ComboBox FieldLabel="公司领导审核状态"  Disabled="true"  ID="TfBoss_Status" runat="server" EmptyText="请选择" Editable="false">
                                                <Items>
                                                    <ext:ListItem Text="未审核" Value="0" />
                                                    <ext:ListItem Text="同意" Value="1" />
                                                    <ext:ListItem Text="退回" Value="2" />
                                                </Items>
                                            </ext:ComboBox>
                                        </ext:Anchor>
                                        <ext:Anchor Horizontal="100%">
                                            <ext:TextArea ID="TfBoss_Remark" Disabled="true"  runat="server" FieldLabel="公司领导审核意见"></ext:TextArea>
                                        </ext:Anchor> 
                                        
                                        
                                    </ext:FormLayout>
                                </Body>
                                <Buttons>
                                    <ext:Button ID="Button1" runat="server" Icon="Disk" Text="提交">
                                    <AjaxEvents>
                                        <Click OnEvent="SubClick">
                                            <EventMask ShowMask="true" Msg="员工诚信档案记录表（审核）提交中..." MinDelay="1000" />
                                        </Click>
                                    </AjaxEvents>
                                    </ext:Button>                                    
                                </Buttons>
                            </ext:FormPanel>
                </ext:LayoutColumn>
                </Columns>
            </ext:ColumnLayout>
        </Body>
    </ext:ViewPort>
    <ext:Window ID="Window1" runat="server" Closable="false"  Modal="true"  Collapsible="false"  ShowOnLoad="false" Icon="ErrorGo" Title="错误">
        <Body>
        <br />
              <ext:Label runat="server" ID="ErrLabel" Text="您没有此项操作的权限！" Icon="Error"></ext:Label>
        </Body>
    </ext:Window>
</asp:Content>

